// 封装的是所有和组织架构相关的接口请求方法
import http from '@/utils/request'

// 因为这个文件将来会导出多个方法,  按需导出 => 别人要用, 按需导入

/**
 * 获取部门列表
 */
export const reqGetDepartments = () => {
  return http({
    method: 'get',
    url: '/company/department'
  })
}

/**
 * 根据id删除部门
 * @param {*} id 部门id
 */
export const reqDelDepartment = (id) => {
  return http({
    method: 'delete',
    url: `/company/department/${id}`
  })
}

/**
 * 新增部门
 * @param {*} obj { name, code, manager, introduce, pid }
 */
export const reqAddDepartment = (obj) => http({
  method: 'post',
  url: '/company/department',
  data: obj
})

/**
 * 获取部门详情
 */
export const reqGetDepartDetail = (id) => {
  return http({
    method: 'get',
    url: `/company/department/${id}`
  })
}

/**
 * 更新部门详情
 * @param {*} form form里面必须有id
 */
export const reqUpdateDepartDetail = (form) => {
  return http({
    method: 'put',
    url: `/company/department/${form.id}`,
    // patch put  post   => data
    // delete  get  => params
    data: form
  })
}
